package com.google.code.chaotic.model;

import java.util.ArrayList;
import java.util.List;

import com.google.code.chaotic.dto.EndType;

public class ModelUtils {

	public static LatLon meanLatLon(List<LatLon> latLons) {
		double lat = 0;
		double lon = 0;
		for (LatLon latLon : latLons) {
			lat += latLon.getLatitude();
			lon += latLon.getLongitude();
		}
		int size = latLons.size();
		return new LatLon(lat / size, lon / size);
	}

	// public static List<LatLon> extractHabitEnds( //
	// List<HabitInService> hisList, EndType endType) {
	//
	// ArrayList<LatLon> ends = new ArrayList<LatLon>(hisList.size());
	//
	// for (HabitInService his : hisList)
	// ends.add(endType == EndType.ORIG ? his.getHabit().getOrigin() //
	// : his.getHabit().getDestination());
	//
	// return ends;
	// }

	public static List<LatLon> extractHabitEnds( //
			List<CommutingHabit> habitList, EndType endType) {

		ArrayList<LatLon> ends = new ArrayList<LatLon>(habitList.size());

		for (CommutingHabit habit : habitList)
			ends.add(endType == EndType.ORIG ? habit.getOrigin() //
					: habit.getDestination());

		return ends;
	}
}
